package com.gigmissions.client.ui;

import com.gigmissions.client.config.GigMissionsMessages;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;
import com.google.inject.Inject;
import com.google.inject.Singleton;


@Singleton
public class ProfilePanel extends VerticalPanel {

	private TextBox facebookUrlTextbox;
	private TextBox myspaceUrlTextbox;
	private TextBox youTubeUrlTextbox;
	private ListBox countryListBox;
	private Button updateButton;
	private GigMissionsMessages messages;
	
	@Inject
	public ProfilePanel(FlexTable layout,
						TextBox facebookUrlTextbox,
						TextBox myspaceUrlTextbox,
						TextBox youTubeUrlTextbox,
						ListBox countryListBox,
						Button updateButton,
						UploadPictureForm uploadAvatar,
						GigMissionsMessages messages){
		
		this.facebookUrlTextbox = facebookUrlTextbox;
		this.myspaceUrlTextbox = myspaceUrlTextbox;
		this.youTubeUrlTextbox = youTubeUrlTextbox;
		this.updateButton = updateButton;
		this.messages = messages;
		this.countryListBox = countryListBox;

		String[] countries = this.messages.countryList().split(",");
		for(String country:countries){
			this.countryListBox.addItem(country);
		}
		
		 
	    layout.setCellSpacing(6);
	    FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();

	    // Add a title to the form
	    layout.setHTML(0, 0, messages.profileFormTitle());
	    cellFormatter.setColSpan(0, 0, 2);
	    cellFormatter.setHorizontalAlignment(0, 0,
	     HasHorizontalAlignment.ALIGN_LEFT);

	    // Add some standard form options
	    layout.setHTML(1, 0, messages.profileCountrySelectLabel());
	    layout.setWidget(1, 1,this.countryListBox);
	    layout.setHTML(2, 0, messages.profileFormFacebookUrlLabel());
	    layout.setWidget(2, 1,this.facebookUrlTextbox);
	    layout.setHTML(3, 0, messages.profileFormMySpaceUrlLabel());
	    layout.setWidget(3, 1, this.myspaceUrlTextbox);
	    layout.setHTML(4, 0, messages.profileFormYouTubeUrlLabel());
	    layout.setWidget(4, 1, this.youTubeUrlTextbox);
	    layout.setHTML(5, 0, messages.uploadPicture());
	    layout.setWidget(5,1, uploadAvatar);

	    // Wrap the content in a DecoratorPanel
	   	
	    this.add(layout);
		
		
	}
	
	
	


	public TextBox getFacebookUrlTextbox() {
		return facebookUrlTextbox;
	}

	public TextBox getMyspaceUrlTextbox() {
		return myspaceUrlTextbox;
	}

	public TextBox getYouTubeUrlTextbox() {
		return youTubeUrlTextbox;
	}

	public ListBox getCountryListBox() {
		return countryListBox;
	}

	public Button getUpdateButton() {
		return updateButton;
	}
	
	
	
}
